// https : // iai.sh.cn/problem/361
#include <bits/stdc++.h>
using namespace std;
const int M = 100001;
int a[M];
int n, m;

bool check(int k) {
  int sum = 0;
  int day = 0;

  for (int i = 1; i <= m; i++) {
    sum += a[i];

    while (sum >= k) {
      sum /= 2;
      day++;
      if (day >= n)
        return true;
    }
  }
  return day >= n;
}
int main() {

  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a[i];
  }
  int L = 0, R = 2000000000;
  int ans;
  while (L <= R) {
    int mid = (L + R) >> 1;
    // cout << L << " " << R << " " << mid << endl;
    if (check(mid)) {
      ans = mid;
      L = mid + 1;
    } else {
      R = mid - 1;
    }
  }
  cout << ans;
  return 0;
}